from django.contrib import admin
from .models import Article, ArticleContent, ArticleComment, ArticleColumn, ArticleTag


class ArticleContentInline(admin.TabularInline):
    model = ArticleContent


class ArticleCommentInline(admin.TabularInline):
    model = ArticleComment
    extra = 1


# Register your models here.
@admin.register(ArticleColumn)
class ArticleColumnAdmin(admin.ModelAdmin):
    list_display = ('column', 'user', 'created')


@admin.register(ArticleTag)
class ArticleTagAdmin(admin.ModelAdmin):
    list_display = ('tag', 'user')


@admin.register(Article)
class ArticleAdmin(admin.ModelAdmin):
    list_display = ('title', 'author', 'publish_date', 'update_date', 'status', 'type', 'scope', 'reading_volume')
    list_filter = ('publish_date', 'author')
    search_fields = ('title',)
    raw_id_fields = ('author',)
    date_hierarchy = 'publish_date'
    ordering = ['publish_date', 'author']
    inlines = [ArticleContentInline, ArticleCommentInline]
